home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 27 / CU Amiga Magazine's Super CD-ROM 27 (1998)(EMAP Images)(GB)[!][issue 1998-10].iso / CUCD / Programming / BlitzList / BlitzListFiles / CPU / FastGfx0.3.lha.lha / FastGfx.readme < prev    next >
Encoding:
Text File  |  1998-05-25  |  11.0 KB  |  273 lines

  1.  
  2.  FastGfx V0.2a By David Newton (dave@nbsamiga.demon.co.uk)
  3.  
  4.  
  5. INTRODUCTION:
  6.  
  7.  FastGfx is a complete set of BlitzBasic2 routines to do all your required
  8. gfx work using the cpu (instead of the blitter) so that FastMem can be used
  9. instead of ChipMem. This set of routines can be used to render all your
  10. software's graphics to a temporary fastmemory bitmap, and then copied to
  11. your screens bitmap. Alternately, you can just use fastmemory shapes, and
  12. draw directly to chipmemory bitmaps.
  13.  
  14.  
  15. DISCLAIMER:
  16.  
  17. THIS SOFTWARE IS SUPPLIED 'AS IS' : THE ENTIRE RISK AS TO THE USE OF THE
  18. SOFTWARE IS ASSUMED BY THE USER. IN NO EVENT WILL THE AUTHOR BE LIABLE
  19. FOR DIRECT OR INDIRECT DAMAGE OR LOSS RESULTING FROM THE USE/MISUSE OF
  20. THIS SOFTWARE.
  21.  
  22.  
  23. USAGE:
  24.  
  25. Here is a list of all the routines included with FastGfx, and the required
  26. input and output (if any). Some of the routines are functions so that you
  27. can test to see if the routine was successful.  Those routines that are
  28. functions will have a * against it, and this means it returns true or
  29. false, meaning whether the function was able to perform it's task without
  30. any problems. All the routines names are case sensetive.
  31.  
  32.  
  33. *InitFastShape{MaxFastShape}
  34.  
  35. This routine sets up the FastGfx shape system for a maximum number of
  36. MaxFastShape shapes to be used. You need to call this before any 
  37. shape/blit/block routines are called. If this function returns false,
  38. then you can't use the shape system as there's been a problem (some
  39. memory problem), so you would need to do some form of error checking, and
  40. inform the user and quit the program. If you don't use any of the 
  41. shape/blit/block routines in your program, then you don't need to call this.
  42.  
  43.  
  44. RemoveFastShapes{}
  45.  
  46. This routine kills ALL FastGfx shapes, and frees all the memory for all the
  47. shapes. You don't need to call this as Blitz will free all the memory at the
  48. end of the program (with END). If you call this in your program, do not make
  49. any more shape/blit/block calls after, as this will almost certainly crash.
  50.  
  51.  
  52. FreeFastShape{FastShape}
  53.  
  54. This routine frees the graphic memory (and mask) of FastGfx shape number
  55. FastShape. You can then later make a new shape in this shape, but until
  56. then, you won't be able to use this shape.
  57.  
  58.  
  59. *MakeBitmap{Bitmap,Width,Height,Depth,Memory}
  60.  
  61. This routine makes a standard blitz bitmap, that is compatible with blitz,
  62. and also compatible with the FastGfx routines. Simply pass the bitmap number
  63. to create, and the width and height and depth of the bitmap. You also need
  64. to pass the Memory Type you want the bitmap to be allocated with. This is
  65. a standard amiga memory type value (as used by Exec), and you will find
  66. a brief description of these in the CONSTANTS section of this document.
  67. This routine will return true or false depending whether the bitmap was
  68. created or not. If you create a CHIPMEM bitmap, then all the standard
  69. blitz drawing and graphics functions will work on the bitmap, if
  70. you choose fastmemory, only FastGfx will be able to render to that bitmap.
  71.  
  72.  
  73. *TestCpuBitmap{Bitmap}
  74.  
  75. This routine tests a standard blitz bitmap to see if it is compatible with
  76. the FastGfx set of routines. Simply pass the number of the blitz bitmap you
  77. wish to test. This should be done on all bitmaps not made using the 
  78. MakeBitmap FastGfx command (above). If this returns false, it means that
  79. you can not use the FastGfx graphics commands on this bitmap, and so you 
  80. should inform the user, and exit. MakeBitmap always makes bitmap's that 
  81. work with FastGfx, this was only included so you could test a screens 
  82. bitmap, or a standard blitz bitmap for compatiblity.
  83.  
  84.  
  85. SetCpuBitmap{Bitmap}
  86.  
  87. This routine sets the blitz bitmap passed to be used for all the FastGfx
  88. routines. This is similar to the blitz Use Bitmap command, and makes all
  89. further routines output/input to and from this bitmap. Just supply the
  90. blitz bitmap number. This must be done atleast once, to direct all the
  91. routines to a bitmap. You must call this to be able to output any gfx
  92. at all!
  93.  
  94.  
  95. SetCpuScroll{Bitmap}
  96.  
  97. This routine is similar to the SetCpuBitmap routine. This sets the source
  98. bitmap for any further scroll routine calls. This must be set atleast once
  99. for any scroll calls to be used. The idea behind having a set scroll source
  100. routine is that usually, you want to copy from the same source everytime,
  101. and this allows you to set the source once, and you can still change the
  102. source for further scroll routine calls by using this routine again.
  103.  
  104.  
  105. CpuBlockScroll{XSrc,YSrc,Width,Height,XDest,YDest}
  106.  
  107. This routine copies a section of the source bitmap (the source bitmap is
  108. set using the SetCpuScroll routine) from XSrc,YSrc to XDest,YDest on the
  109. destination bitmap (the source and destination can be the same). The
  110. destination bitmap is the currently used FastGfx bitmap (set by using the
  111. SetCpuBitmap routine). The Width and Height of the block are specified
  112. using Width and Height. This is the BLOCK version of the Scroll command,
  113. which means that all X positions, and the Width, must be a multiple of 16
  114. pixels. (ie, X could be 0,16,32,48,64 etc). This is faster than the normal
  115. CpuScroll command, and should be used for moving big chunks of bitmaps
  116. around.
  117.  
  118.  
  119. GetFastShape{FastShape,X,Y,Width,Height}
  120.  
  121. This routine grabs a FastGfx shape from the currently used FastGfx bitmap
  122. (set by SetCpuBitmap) into the FastGfx shape number FastShape. This can
  123. be used to get any size shape, and from any x and y positions (on the 
  124. bitmap). It will also make a mask for the shape.
  125.  
  126.  
  127. FreeFastCookie{FastShape}
  128.  
  129. This routine frees a FastGfx shape's mask. This is only useful if you want
  130. to output the shape using the block command, as the block command doesn't
  131. require a mask. You can not blit the shape after calling this, as it has
  132. no mask.
  133.  
  134.  
  135. MakeFastCookie{FastShape}
  136.  
  137. This routine makes a mask for a FastGfx shape. This is only useful if you
  138. have free the mask using the FreeFastCookie routine, or if you have change
  139. the shape's graphics.
  140.  
  141.  
  142. CpuBlit{FastShape,X,Y}
  143.  
  144. This routine blits the FastGfx shape number FastShape, onto the currently
  145. used bitmap (set by using SetCpuBitmap) at x,y. There is no clipping, and
  146. it can be blitted to any x and y position on the bitmap. The bitmap must
  147. have the same (or bigger) depth, otherwise the blit will not work correctly.
  148. This uses the FastGfx shape's mask to merge with the bitmap's contents.
  149.  
  150.  
  151. CpuBlock{FastShape,X,Y}
  152.  
  153. This routine blocks the FastGfx shape number FastShape, onto the currently
  154. used bitmap (set by using SetCpuBitmap) at x,y. There is no clipping, and
  155. it can only be blocked to x positions that are a multiple of 16, whereas
  156. y can be any number. The bitmap must have the same (or bigger) depth,
  157. otherwise the block will not work correctly. This doesn't use the FastGfx
  158. shape's mask and therefore replaces any graphics that were under this shape
  159. on the bitmap.
  160.  
  161.  
  162. To Include this set of routines into your program you need to add two lines
  163. to your program and add a resident file (if it's not there already) in
  164. compiler options.
  165.  
  166. 1) Add the following line to your program (somewhere near the top)
  167.  
  168. #FGFX_COMPACT=0
  169.  
  170. 2) Add the following line to your program (somewhere near the top)
  171.  
  172. Include "FastGfx.bb2"
  173.  
  174. 3) Go to Compiler Options, and in the resident box, enter
  175.  
  176. BlitzLibs:bb2objtypes.res
  177.  
  178.  
  179. You should know be able to call the above routines, and use the FastGfx
  180. system. If that didn't work, try looking for the file bb2objtypes.res, and
  181. if you haven't got it..find someone that does. If that's not the problem,
  182. have you copied the include to your current source directory??? Or just
  183. simply put the path where this readme and the FastGfx.bb2 file is infront
  184. of the filename in the include statement. If all else fails try emailing
  185. me :). Good Luck
  186.  
  187. The #GFX_COMPACT constant is actually a flag to tell the include to
  188. compile certain routines instead of others. If this equals 0, then the
  189. compiler will compile all the slightly faster hardcoded depth routines,
  190. which take up more memory, and if this equals 1, then the compiler
  191. will compile all the non hardcoded slightly slower routines, that take up
  192. less memory and space.
  193.  
  194. There are some constants in the include file, and these allow you to turn
  195. off whole sections of the FastGfx includes. Say your program wanted the
  196. drawing routines only, then you could turn off the shapes, and it won't
  197. compile those routines, and take up less memory......and vice versa, so
  198. you can make your program as compact as possible.
  199.  
  200.  
  201. EXAMPLE:
  202.  
  203. > Assumes you have included the FastGfx file above here, and set the
  204. > constant #FGFX_COMPACT before that, and setup the resident file as above.
  205.  
  206. If InitFastShape{20}=false then end        ;this quits if the shape setup
  207.                                     ;wasn't successful.
  208.  
  209. If MakeBitmap{0,320,256,5,0}=false then end    ;this quits if the make bitmap
  210.                                          ;wasn't successful.
  211.  
  212. SetCpuBitmap{0}                        ;now set the bitmap to use
  213.                                     ;for the FastGfx routines.
  214.  
  215. GetFastShape{0,0,0,16,16}                ;Get FastGfx shape 0. It will
  216.                                     ;be grabbed from the current
  217.                                     ;bitmap (SetCpuBitmap) starting
  218.                                              ;at 0,0 and make it 16 pixels 
  219.                                            ;wide, and 16 lines high.
  220.  
  221. CpuBlit{0,100,100}                        ;Now blit that same shape
  222.                                     ;back to the current bitmap
  223.                                     ;(SetCpuBitmap) starting at
  224.                                      ;100,100
  225.  
  226. End                                    ;now end, and free all the
  227.                                     ;Fast Gfx data automatically!
  228.  
  229.  
  230. NOTES:
  231.  
  232. This will only work on planar bitmaps at the moment (ie, non chunky). It
  233. will also not work correctly on interleaved bitmaps (though that's planned).
  234.  
  235. All bitmap MUST be allocate continuosly.....Use MakeBitmap to create
  236. a bitmap that can be used by these functions (or use cludgebitmap). If
  237. you make a bitmap in chipmemory, it can be accessed by normal blitz
  238. commands as well as the cpu functions. If you use screensbitmap, I'd
  239. advise checking that it is useable with the cpu functions, by using the
  240. TestCpuBitmap function. AFAIK, most screens in newer amigas are continuous
  241. but some can be interleaved. The test will not be able to tell if the
  242. screens bitmap is chunky, but then you shouldn't be using screensbitmap
  243. on chunky screens (gfx card screens) as they are not the same as normal
  244. amiga screens/bitmaps.
  245.  
  246. All the save and load routines use blitz's file 0. So don't have any files
  247. open using file 0, when you call a save or load routine.
  248.  
  249. You have a maximum of 32767 shapes available, and the limit for bitmaps and
  250. shape sizes are 32000x32000 (pixels by lines). You can have a depth of 1
  251. to 8, and you should always output your shapes to a similar (or bigger)
  252. depth bitmap. The Scroll command takes the lowest depth bitmap and only
  253. copies those number of bitplanes.
  254.  
  255. This isn't supposed to be a complete gfx answer, but it should be usefull
  256. for 90% of the things you want to do.
  257.  
  258. I could have made a user library of these...but I didnt...for a few reasons,
  259.  
  260. 1) I can change things easier, and include it directly in the program
  261. 2) I think there are enough bad user librarys about already
  262. 3) I have some clever space saving stuff which couldn't be done
  263.    using a library
  264. 4) The user can modify things, and create their own specific routines
  265.  
  266.  
  267. TO-DO:
  268.  
  269. Chunky compatible bitmaps and shapes and routines
  270. Interleaved bitmaps
  271. Text outputing
  272. Examples of my routines in action
  273.